import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'
import login from '@/components/Login'
import agent from '@/components/Agent'
import glogin from '@/components/GenesysLogin'


Vue.use(Router)
// import VueSocketIO from 'vue-socket.io'

var router = new Router({
    routes: [
        {
            path: '/',
            name: 'login',
            component: login
        },
        {
            path: '/glogin',
            name: 'glogin',
            component: glogin
        },
        {
            path: '/agent',
            name: 'agent',
            component: agent
        },
    ]
})

router.beforeEach(function (to, from, next) {
    console.log(from);
    console.log(to);
    console.log(next);
    if (to.name == null) {
        //找不到跳转的页面，去登录页面
        next({
            path: '/',
        })
    } else {
        next();
    }
})

export default router